package com.elcom.roaming.module.synthesis.pr;

import com.elcom.roaming.common.config.ConfigModule;
import com.elcom.roaming.common.util.match.ObjectKey;

public class PRKey extends ObjectKey{

	int seq;
	String orgTransId;
	String termTransId;
	
	public PRKey(int seq, String time, String orgTransId, String termTransId) {
		this.seq = seq;
		this.setPutTime(time);
		this.orgTransId = orgTransId;
		this.termTransId = termTransId;
	}
	
	@Override
	public boolean equals(Object obj) {
		if (!(obj instanceof PRKey)) return false;
		
		PRKey cmpObj = (PRKey) obj;
		if (this == cmpObj) return true;

		if (this.getPutTimeInMs() - cmpObj.getPutTimeInMs() < ConfigModule.MISS_CALL_TIMEOUT * 1000 &&
				this.orgTransId.equals(cmpObj.termTransId) &&
				this.termTransId.equals(cmpObj.orgTransId)) return true;
		
		return false;
	}

	@Override
	public int hashCode() {
		return orgTransId.hashCode() * termTransId.hashCode();
	}

	@Override
	public String toString() {
		return "seq=" + seq +
				"|time=" + getPutTime() +
				"|orgTransId=" + orgTransId +
				"|termTransId=" + termTransId;
	}

}
